    function JsXMLHttpRequest()
    {

    }

    function GetXHR()
    {
        var httpRequest;

        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            httpRequest = new XMLHttpRequest();
            /*if (httpRequest.overrideMimeType) {
                httpRequest.overrideMimeType('text/xml');
                // See note below about this line
            }*/
        } else if (window.ActiveXObject) { // IE
            try {
                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {
                    if (jsRequest) {
                        httpRequest = new JsXMLHttpRequest();
                    }
                }
            }
        }

        if (!httpRequest) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        return httpRequest;
    }

    function makeRequest(url, httpRequest, handler, a, data, method)
    {

        httpRequest.onreadystatechange = function()
        {
            if (httpRequest.readyState == 4) {
                if (httpRequest.status == 200) {
                    if (httpRequest.responseXML) {
                        handler(httpRequest);
                    } else {
                        //alert('Response a empty.');
                    }
                } else {
                    alert('There was a problem with the request.');
                }
            }
        };
        httpRequest.open(method||'GET', url, a||true);
        httpRequest.send(data||null);
    }

    var httpRequest = GetXHR();

    function ajaxInit()
    {
    }

    var erase = true;
    var page = null;
    var main = null;
    var gradient = null;
    var drag = false;
    var cl1 = 255;
    var cl2 = 255;
    var bgcolor = Math.min(cl1, cl2);
    var sampleds = Array();

    function initHandler(httpRequest)
    {
        var colors = httpRequest.responseXML.getElementsByTagName('colors').item(0).childNodes;
        cl1 = Number(colors.item(0).firstChild.data);
        cl2 = Number(colors.item(1).firstChild.data);
        for (var i=0; i<sampleds.length; i++) {
            var strColor1 = cl1.toString(16);
            strColor1 = strColor1.length==1 ? "0"+strColor1 : strColor1;
            sampleds[i].style.backgroundColor = "#" + strColor1 + strColor1 + strColor1;
            sampleds[i].style.backgroundImage = "url('pixel.php?type=sample&cl=" + cl2.toString(10) + "')";
        }
        var brick = page.getElementById("table");
        var parentOldNode = brick.parentNode;
        parentOldNode.replaceChild(XmlDomElement2HtmlDomElement(httpRequest.responseXML.getElementsByTagName('message').item(0).firstChild), brick);
    }

    function init()
    {
        page = window.document;
        main = page.getElementById("main");
        gradient = page.getElementById("gradient");
        tmp_sampleds = page.getElementsByTagName("div");
        for (var i=0; i<tmp_sampleds.length; i++) {
            var tmp = tmp_sampleds[i];
            if (tmp.className=="sampled") {
                sampleds[sampleds.length] = tmp;
            }
        }
        if (httpRequest) {
            makeRequest("http://localhost/graphic.php?erase=1", httpRequest, initHandler);
        }
    }

    function SliderOnMouseMove(owner, event)
    {
        var realOffset = event.clientX - owner.offsetLeft;
        var realOffset = realOffset<0 ? 0 : (realOffset>=owner.clientWidth ? owner.clientWidth-1 : realOffset);
        var offsetLeft = realOffset/owner.clientWidth;
        bgcolor = Math.round(Math.min(cl1, cl2) + offsetLeft * Math.abs(cl1 - cl2));
        var color = bgcolor.toString(16);
        color = color.length==1 ? "0"+color : color;
        main.style.backgroundColor = "#" + color + color + color;
        SlideOnMove(owner.parentNode, realOffset);
    }

    function SlideOnMove(slide, offset)
    {
        var marker = slide.getElementsByTagName("div").item(0);
        marker.style.left = (5 + offset).toString(10) + "px";
    }

    function mouseDown(owner, event)
    {
        if (httpRequest) {
            makeRequest("http://localhost/graphic.php?result=" + bgcolor.toString(10) + "&cl[]=" + cl1.toString(10) + "&cl[]=" + cl2.toString(10), httpRequest, initHandler);
        }
    }

    function reset(owner, event)
    {
        if (httpRequest) {
            makeRequest("http://localhost/graphic.php?erase=1", httpRequest, initHandler);
        }
    }

    function env(owner, event)
    {
        if (httpRequest) {
            makeRequest("http://localhost/graphic.php?env=1", httpRequest, initHandler, 1, "Hello, World!", "POST");
        }
    }